<?php

namespace app\admin\controller\merchant;

class Shareholder extends Base
{
	protected $model = null;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = loader('admin')->loadModel('sh\\Shareholder');
    }

    public function index()
    {
    	//设置过滤方法
        $this->request->filter(['strip_tags', 'trim']);
        if ($this->request->isAjax()) {
            //如果发送的来源是Selectpage，则转发到Selectpage
            if ($this->request->request('keyField')) {
                return $this->selectpage();
            }
            $filter = $this->request->param('filter');
            $filter = json_decode($filter, true);
            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
            $list = $this->model
                ->where($where)
                ->order($sort, $order)
                ->paginate($limit);
            $result = array("total" => $list->total(), "rows" => $list->items());
            return json($result);
        }

        return $this->view->fetch();
    }
}